import { Entity, PrimaryGeneratedColumn, ManyToOne, JoinColumn } from 'typeorm';
import { User } from './user.entity';
import { Role } from './role.entity';

/**
 * 用户角色表
 */
@Entity('sys_user_role')
export class UserRole {
  /**
   * 用户角色表
   */
  @PrimaryGeneratedColumn({ comment: '用户角色表id' })
  userRoleId: number;

  /**
   * 用户id
   */
  @ManyToOne(() => User, (user) => user.userRoles)
  @JoinColumn({ name: 'userId' })
  user: User;

  /**
   * 角色id
   */
  @ManyToOne(() => Role, (role) => role.roleUsers)
  @JoinColumn({ name: 'roleId' })
  role: Role;
}
